#parse obj file
#struct
import numpy
class Material:
    name=""
    ambient="vector3"
    alpha=0.0
    ambientTex=""
class Face:
    pos=3
    normal=3
    uv=3
    material=1
#顶点
vertex_array=[]
#f
index_order_array=[]
#法线
vn_points_array=[]
def load():
    print("输入obj文件路径")
    obj_file_path="output.obj"#input()
    file=open(obj_file_path,"r")
    parse(file)
    pass

def get_normals():
    pass
def parse(file):
    for i in file.readlines():
        if "#" in i:
            print("注释 跳过")
        if "mtllib" in i:
            print("有材质")
            
        if "v" in i:
            points={}
            split_v=i.split("v")[1].strip()
            points["x"]=split_v.split(" ")[0]
            points["y"]=split_v.split(" ")[1]
            points["z"]=split_v.split(" ")[2]
            # points["z"]=i
            vertex_array.append(points)
            #print("找到顶点")
        #法线
        if "vn" in i:
            vn_points={}
            split_vn=i.split("vn")[1].strip()
            vn_points["x"]=split_vn.split(" ")[0]
            vn_points["x"]=split_vn.split(" ")[1]
            vn_points["x"]=split_vn.split(" ")[2]
            vn_points_array.append(vn_points)
        if "f" in i:
            #print("开始连线")
            f_index_order={}
            split_f=i.split("f")[1].strip()
            #f 1 1 1 f 2/2/2 3/3/3 4/4/4 最前面的才是顶点连线索引顺序
            f_index_order[1]=split_f.split(" ")[0].split("/")[0]
            #y z
            index_order_array.append(f_index_order)
            break
    #print(points_array)
    #return points_array